import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls 2.12

Item
{
    id: root
    width: 640
    height: 480

    property date dateStart: new Date()
    property date dateEnd: new Date()
    property int recallWhich: 1

    Component.onCompleted: {
        calendar_start.visible = false;rectangle_timeStart.visible= false
        calendar_stop.visible = false;rectangle_timeStop.visible= false
    }

    Button{
        x: 120
        y: 400
        width: 130
        height: 40
        text: qsTr("确认")
        scale: pressed?0.9:1
        font.pointSize: 20
        font.family: "Verdana"

        background: Rectangle{
            color: "#88eabf88"
            radius: 10
        }

        onClicked: {
            excRecordDisplayer.sl_showLoadSettingUI(0)
            if(recallWhich == 1)
                excRecordDisplayer.sl_settingFinishChart()
            else if(recallWhich == 2)
                excRecordDisplayer.sl_settingFinishTable()
        }
    }

    Button{
        x: 420
        y: 400
        width: 130
        height: 40
        text: qsTr("取消")
        scale: pressed?0.9:1
        font.pointSize: 20
        font.family: "Verdana"

        background: Rectangle{
            color: "#88eabf88"
            radius: 10
        }

        onClicked: {
            excRecordDisplayer.sl_showLoadSettingUI(0)
        }
    }

    Rectangle {
        id: rectangle_textStart
        x: 50
        y: 50
        width: 250
        height: 30
        color: "#88a8d3ba"
        radius: 10
        TextEdit {
            id: te_startDate
            text: dateStart.toLocaleString(Qt.locale("de_DE"), "yyyy-MM-dd HH:mm:ss:zzz")
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            font.pixelSize: 20
        }
        MouseArea {
            id: ma_startDate
            anchors.fill: parent
            onClicked: {
                if(calendar_start.visible == false){calendar_start.visible = true;rectangle_timeStart.visible= true}
                else{calendar_start.visible = false;rectangle_timeStart.visible= false}
            }
        }
    }

    Calendar{
        id: calendar_start
        width: 250
        height: 264
        anchors.left: rectangle_textStart.left
        anchors.top: rectangle_textStart.bottom
        activeFocusOnTab: true
        onDoubleClicked: {
            var t_date = new Date()
            t_date.setFullYear(date.getFullYear())
            t_date.setMonth(date.getMonth())
            t_date.setDate(date.getDate())
            t_date.setHours(tumbler_startHour.currentIndex)
            t_date.setMinutes(tumbler_startMin.currentIndex)
            t_date.setSeconds(tumbler_startSec.currentIndex)
            t_date.setMilliseconds(tumbler_startMinSec.currentIndex)
            dateStart = t_date
            visible = false
            rectangle_timeStart.visible = false
        }
    }

    Rectangle {
        id: rectangle_timeStart
        height: parent.height*0.2
        color: "#ffffff"
        anchors.right: calendar_start.right
        anchors.left: calendar_start.left
        anchors.top: calendar_start.bottom

        Tumbler {
            id: tumbler_startHour
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 24
        }
        Tumbler {
            id: tumbler_startMin
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: tumbler_startHour.right
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 60
        }
        Tumbler {
            id: tumbler_startSec
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: tumbler_startMin.right
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 60
        }
        Tumbler {
            id: tumbler_startMinSec
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: tumbler_startSec.right
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 1000
        }
    }

    Rectangle {
        id: rectangle_textStop
        x: 350
        y: 50
        width: 250
        height: 30
        color: "#88a8d3ba"
        radius: 10
        TextEdit {
            id: te_stopDate
            text: dateEnd.toLocaleString(Qt.locale("de_DE"), "yyyy-MM-dd HH:mm:ss:zzz")
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            font.pixelSize: 20
        }
        MouseArea {
            id: ma_stopDate
            anchors.fill: parent
            onClicked: {
                if(calendar_stop.visible == false){calendar_stop.visible = true;rectangle_timeStop.visible= true}
                else{calendar_stop.visible = false;rectangle_timeStop.visible= false}
            }
        }
    }

    Calendar{
        id: calendar_stop
        width: 250
        height: 264
        anchors.left: rectangle_textStop.left
        anchors.top: rectangle_textStop.bottom
        activeFocusOnTab: true
        onDoubleClicked: {
            var t_date = new Date()
            t_date.setFullYear(date.getFullYear())
            t_date.setMonth(date.getMonth())
            t_date.setDate(date.getDate())
            t_date.setHours(tumbler_stopHour.currentIndex)
            t_date.setMinutes(tumbler_stopMin.currentIndex)
            t_date.setSeconds(tumbler_stopSec.currentIndex)
            t_date.setMilliseconds(tumbler_stopMinSec.currentIndex)
            dateEnd = t_date
            visible = false
            rectangle_timeStop.visible = false
        }
    }

    Rectangle {
        id: rectangle_timeStop
        height: parent.height*0.2
        color: "#ffffff"
        anchors.right: calendar_stop.right
        anchors.left: calendar_stop.left
        anchors.top: calendar_stop.bottom

        Tumbler {
            id: tumbler_stopHour
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 24
        }
        Tumbler {
            id: tumbler_stopMin
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: tumbler_stopHour.right
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 60
        }
        Tumbler {
            id: tumbler_stopSec
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: tumbler_stopMin.right
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 60
        }
        Tumbler {
            id: tumbler_stopMinSec
            font.pointSize: 12
            visibleItemCount: 4
            anchors.left: tumbler_stopSec.right
            anchors.bottom: parent.bottom
            anchors.top: parent.top
            model: 1000
        }
    }

    function setStartTime(var1)
    {
        dateStart = var1
    }

    function setEndTime(var1)
    {
        dateEnd = var1
    }

}



/*##^##
Designer {
    D{i:5;anchors_width:200}
}
##^##*/
